<template>
  <view class="main">
    <NavBar title="登录" />
    <div class="m1">
      <div class="cell ub ub-ac">
        <div class="tit">企业代码</div>
        <input class="ub-f1 tx-l" :value="orgCode" type="text" placeholder="企业代码" @input="bindInput($event, 'orgCode')" />
      </div>
      <div class="cell ub ub-ac btc">
        <div class="tit">用户账号</div>
        <input class="ub-f1 tx-l" :value="userAccount" type="text" placeholder="用户账号" @input="bindInput($event, 'userAccount')" />
      </div>
      <div class="cell ub ub-ac btc">
        <div class="tit">密码</div>
        <input class="ub-f1 tx-l" :value="password" type="password" placeholder="密码" @input="bindInput($event, 'password')" />
      </div>
    </div>
    <div class="ub ub-pe" style="margin-top:16rpx;padding-right:30rpx">
      <div @click="toUpdate">忘记密码?</div>
    </div>
    <button form-type="submit" type="primary" class="btn" @click="submit">登 录</button>
  </view>
</template>
<script>
import service from '@/utils/http'
import constant from '@/utils/constant'
import { errDialog, loading } from '@/utils/util'
export default {
  data() {
    return {
      orgCode: '100001',
      userAccount: 'admin',
      password: 'xx123456'
    }
  },
  methods: {
    bindInput(e, param) {
      this[param] = e.detail.value
    },
    toUpdate() {
      uni.navigateTo({ url: '/pages/user/psdforget' })
    },
    submit() {
      if (this.orgCode == '') {
        errDialog('请输入企业代码')
        return
      }
      if (this.userAccount == '') {
        errDialog('请输入用户账号')
        return
      }
      if (this.password == '') {
        errDialog('请输入密码')
        return
      }
      const { orgCode, userAccount, password } = this
      const obj = {
        orgCode,
        userAccount,
        password,
        loginType: 5
      }
      service.post('/app/logon', obj).then(res => {
        uni.setStorageSync('token', res.data)
        uni.showToast({ title: '登录成功', icon: 'none' })
        uni.reLaunch({ url: '/pages/home/index' })
      })
    }
  }
}
</script>
<style scoped>
.m1{ background-color: #fff; padding: 0 30rpx;background: #ffffff;}
.cell {height: 96rpx;background: #fff;}
.cell .tit{width: 140rpx; font-size:28rpx;font-weight: bold;}
.cell input {font-size: 28rpx; color: #333; font-size:28rpx}
.subtit{font-size: 28rpx;color: #333;margin-bottom: 20rpx;}
.uploadImgDiv{width: 620rpx; height: 360rpx;background: #fff;border-radius: 12rpx;margin: 0 auto;}
.uploadImg {
  width: 240rpx;
  height: 360rpx;
  position: relative;
  margin: 0 auto;
}
.uImg {
  width: 240rpx;
  height: 240rpx;
  display: block;
}
.uTxt{
    color: #2784ff;
    font-size: 28rpx;
    margin-top:20rpx
}
.uPlus {
  width: 120rpx;
  height: 120rpx;
  display: block;
}
.btn{margin:60rpx auto 30rpx; width: 650rpx;}
</style>
